
//初始化方法
if($("#uid").val()!=''){
	var jsonCar = {};
	jsonCar['user.uid'] = $("#uid").val();
	loadGoodCar(jsonCar);
}

//加载所有购物车商品
function loadGoodCar(jsonCar){
	$.ajax({
		url: 'car/findManyByPramas',
		type: 'post',
		data:jsonCar,
		success:function(res){
			console.log("购物车",res)
		
				//循环数据集合，通过jquery的append()方法将标签加入到ul中
				var carHtml='';
				var zcprice = 0;
				$('.cart_list').html('');
				//修改这里 res.data 因为我的数据不是map对传回来的
				$.each(res,function(i,car){
		            zcprice = parseFloat(zcprice) + parseFloat(car.cprice);
		            carHtml += '<li style="margin-bottom: 18px;">';
		            carHtml += '<a href="good/goodDetails?gid='+car.good.gid+'">';
		            carHtml += '<p style="margin-bottom: 5px;">'+car.good.gname+'</p>';
		            carHtml += '<img style="width: 60px;height: 60px;" alt="'+car.good.gname+'" src="/zzbinGood/g'+car.good.gid+'/'+car.good.gpicpath+'">';
		            carHtml += '</a><br/>';
		            carHtml += '<span>规格：'+car.goodColor.gcname+'&nbsp;/'+car.goodSize.gsname+'</span><br/><br/>';
		            carHtml += '<span class="quantity">'+car.cnum+' × <span style="color:red;">'+(car.good.price*car.good.discount).toFixed(2)+'</span>';
		            carHtml += ' = <span style="color:red;">'+(car.cprice).toFixed(2)+'</span></span>'
		        });
				$('.cart_list').append(carHtml);
				$('.leftCarSpan').text(zcprice.toFixed(2));
		},
		error:function(){
			swal("加载购物车异常!"," ","warning",{buttons: {}});
		}
	});
}